#include "cylinder.h"


cylinder::cylinder(void)
{
	this->r=0;
	this->h=0;
}

cylinder::cylinder(double r , double h)
{
	this->r=r;
	this->h=h;
}

cylinder::cylinder(std::string id, double r , double h)
	: shape(id,0,0)
{
	this->r=r;
	this->h=h;
}

double cylinder::volume()
{
	return  M_PI*r*r*h;
}

double cylinder::area()
{
	return M_PI*(2*r*h+ 2*r*r);
}

void cylinder::print()
{
	std::cout << "cylinder(" << r << "," << h << ")" << std::endl; 
}

cylinder::~cylinder(void)
{
	//std::cout << "Destruktor cylinder" << std::endl;
}

ostream &operator<<(ostream &stream, cylinder &o)
{
	stream << "(id,x,y,r,h)=(" << o.id << "," << o.x << "," << o.y  << ","  << o.r << "," << o.h << ")";
	return stream;
}

istream &operator>>(istream &stream, cylinder &o)
{
	char c,s[100];
	stream >> c;
	stream.getline(s,99,',');
	o.id = string(s);
	stream >> o.x >> skipws >> c >> o.y >> skipws >> c;
	stream >> o.r >> skipws >> c >> o.h >> skipws >> c;

	return stream;
}

